import { test, expect } from 'bun:test'
/* 自行创建 */
import { scriptToken, webhookURL } from './const-value.ignore'
import { initRemoteCallWpsjsGlobal } from '../index'

test('选区 获取视图', async () => {
  const wpsjsGlobal = initRemoteCallWpsjsGlobal({ scriptToken, webhookURL, printLog: true })
  const info = await wpsjsGlobal.Application.Selection.GetActiveView().execution()
  const keys = ["sheetId", "viewId", "name", "type",]
  expect(Object.keys(info)).toEqual(expect.arrayContaining(keys))
})

/**测试返回 [] 存在bug */
test.todo('选区 获取记录', async () => {
  const wpsjsGlobal = initRemoteCallWpsjsGlobal({ scriptToken, webhookURL, printLog: true })
  const infoArray = await wpsjsGlobal.Application.Selection.GetSelectionRecords().execution()
  const info = infoArray[0]
  const keys = ['id', 'fields']
  expect(Object.keys(info)).toEqual(expect.arrayContaining(keys))
})

test('选区 获取表', async () => {
  const wpsjsGlobal = initRemoteCallWpsjsGlobal({ scriptToken, webhookURL, printLog: true })
  const info = await wpsjsGlobal.Application.Selection.GetActiveSheet().execution()
  const keys = ["sheetId", "name", "description",]
  expect(Object.keys(info)).toEqual(expect.arrayContaining(keys))
})
